package com.luxk.db.block;

import com.luxk.db.data.undo.UndoAddress;
import com.luxk.db.tx.Xid;

public interface BlockTxHeader {
	
	public enum BlockTxState {
		INVALID(0),
		ACTIVE(1),
		COMMIT_FAST(2),
		COMMIT_EXACT(3),
		CPMMIT_UPPER(4);
		
		private static final BlockTxState[] states = {
			INVALID,
			ACTIVE,
			COMMIT_FAST,
			COMMIT_EXACT,
			CPMMIT_UPPER
		};

		private final int val;
		
		BlockTxState(int val) {
			this.val = val;
		}
		
		public int getValue() { return this.val; }
		
		public static BlockTxState getState(int val) {
			return states[val];
		}
		
		public static BlockTxState getState(byte val) {
			return states[val];
		}
	}
	
	public int getTxCount() throws Exception;
	public void setTxCount(int cnt) throws Exception;
	
	public int extendBlockTxEntry() throws Exception;
	public int shrinkBlockTxEntry() throws Exception;
	
	public BlockTxState getBlockTxState(int i) throws Exception;
	public void setBlockTxState(int i, BlockTxState state) throws Exception;
	
	public Xid getBlockTxId(int i) throws Exception;
	public void setBlockTxid(int i, int usgmtId, int wrapNo) throws Exception;
	
	public UndoAddress getUndoAddress(int i) throws Exception;
	public void setUndoAddress(int i, int dba, int seqNo, int rowNo)
			throws Exception;
	
	public long getCommitScn(int i) throws Exception;
	public void setCommitScn(int i, long scn) throws Exception;
	
	public int getCredit(int i) throws Exception;
	public void setCredit(int i, int credit) throws Exception;
	
	public int getTxHeaderSize() throws Exception;
	
	public int extendTxHeader(int incSize) throws Exception;
	public int shrinkTxHeader(int decSize) throws Exception;
}
